home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000095_icon-group-sender _Fri May 14 02:01:30 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 17 May 1993 07:43:52 MST
  2. Received: by owl.cs.arizona.edu; Mon, 17 May 1993 07:43:51 MST
  3. Date: 14 May 93 02:01:30 GMT
  4. From: amethyst!organpipe.uug.arizona.edu!news@noao.edu  (Dave Schaumann)
  5. Organization: University of Arizona
  6. Subject: Re: Icon vs Prolog, docs, availability ?
  7. Message-Id: <1993May14.020130.17872@organpipe.uug.arizona.edu>
  8. References: <borbor-130593120939@129.194.82.105>
  9. Sender: icon-group-request@cs.arizona.edu
  10. To: icon-group@cs.arizona.edu
  11. Status: R
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. In article <borbor-130593120939@129.194.82.105>, borbor@divsun (Boris Borcic) writes:
  15. >I have read in this group that Icon uses a backtracking
  16. >mechanism very similar to Prolog. Would a user of both
  17. >languages care to sketch Icon with Prolog as background ?
  18. >What are the most significant differences ?
  19.  
  20. Probably the most significant difference is that Icon is a (mostly)
  21. imperative language.  Thus, most Icon programs tend to be (mostly)
  22. imperative.
  23.  
  24. On the other hand, I was just working on implementing an algorithm for
  25. which backtracking worked out very nicely.  The algorithm (in part)
  26. maintians a list of sets.  Part of the algorithm is a loop which selects
  27. an element from one of these sets.  The pseudo-code is expressed as
  28.  
  29.   Select a in (size of list) and i in L[a].  The loop terminates when
  30.   L[a] is empty for all a.
  31.  
  32. This can be expressed very nicely in Icon as
  33.  
  34.   while a := 1 to *L & i := !L[a] do {
  35.     # do the loop stuff
  36.     }
  37.  
  38. Here, Icon's backtracking feature is used to elide the fact that (in general)
  39. you have to loop to find appropriate values of a and i.
  40.  
  41. It's been a long time since I did any Prolog programming, so I can't
  42. speak directly to the relative strengths of each language, but I wouldn't
  43. be to surprised if one could write a fairly complete Prolog interpreter
  44. in Icon with relatively few lines of code (particularly since you have the
  45. backtracking feature "for free").
  46.  
  47. -- 
  48. Dave Schaumann            dave@cs.arizona.edu
  49.